import * as types from '../types'
import api from '../../fetch/api'

const state = {
	UserInfo_data: {}, //个人信息
	login_code_start: false, //二维码登录状态码
	login_pass_start: false, //账号密码登录状态码
	login_register_start: false, //注册状态码
	loginRegist: {
		phone: "", // => '请输入电话',
		name: "", //=> '请输入用户名',
		code: "", // => '请输入验证码',
		account: "", //=> '请输入登录名',
		password: "", // => '请输入密码',
		repassword: "", // => '2次密码不一致'}
	},
	loginlogin: {
		name: "", //String	 账号
		password: "", //String	 密码
	}
}
const actions = {
	getUserInfo({ dispatch, commit }, res) {
		commit(types.LOGIN_USERINFO_DATA, res)
	},
	setLogincodestart({ dispatch, commit }, res) {
		commit(types.LOGIN_CODE_START, res.code),
			commit(types.LOGIN_PASS_START, res.pass)
	},
	setLoginpassstart({
		dispatch,
		commit
	}, res) {
		commit(types.LOGIN_CODE_START, res.code),
			commit(types.LOGIN_PASS_START, res.pass)
	},
	setLoginregisterstart({
		dispatch,
		commit
	}, res) {
			commit(types.LOGIN_REGISTER_START, res)
	},
	getloginRegist({
		dispatch,
		commit
	}, res) {
		commit(types.LOGIN_LOGINRGIST_DATA, res)
	},
	getloginLogin({
		dispatch,
		commit
	}, res) {
		commit(types.LOGIN_LOGIN_DATA, res)
	},

}

const getters = {
	UserInfo_data: state => state.UserInfo_data,
	login_code_start: state => state.login_code_start,
	login_pass_start: state => state.login_pass_start,
	login_register_start: state => state.login_register_start,
	loginRegist: state => state.loginRegist,
	loginlogin: state => state.loginlogin,
}

const mutations = {
	[types.LOGIN_USERINFO_DATA](state, res) {
		state.UserInfo_data = res
	},
	[types.LOGIN_CODE_START](state, res) {
		state.login_code_start = res
	},
	[types.LOGIN_PASS_START](state, res) {
		state.login_pass_start = res
	},
	[types.LOGIN_REGISTER_START](state, res) {
		state.login_register_start = res
	},
	[types.LOGIN_LOGINRGIST_DATA](state, res) {
		state.loginRegist = res
	},
	[types.LOGIN_LOGIN_DATA](state, res) {
		state.loginlogin = res
	},
}

export default {
	state,
	actions,
	getters,
	mutations
}
